set more off

use "locallaws", clear
merge 1:m swis_code using "rates"
keep if  year >= 1961 & year <= 1981

gen y = equalization_rate
gen se = y

gen post = year > 1971
reg y post##held i.year, cl(swis_code)

*** collapse ***

collapse y (semean) se, by(year held_referendum)
gen ub = y + 1.96*se
gen lb = y - 1.96*se

*** graph ***

#delimit;

gr tw
	(line ub lb year if held_referendum == 1, lcol(black black) lpat(shortdash shortdash))
	(line ub lb year if held_referendum == 0, lcol(black black) lpat(dot dot))
	(line y year if held_referendum == 0 & year <= 1971, col(black) lpat(dash) lwid(thick))
	(line y year if held_referendum == 0 & year >= 1971, col(black) lpat(dash) lwid(thick))
	(line y year if held_referendum == 1, col(black) lpat(solid) mfcol(white) lwid(thick))
	(scatteri 20 1971 60 1971, c(l) m(i) col(black) lpat(solid) lwid(thin))
	,
		xtitle("Year")
		ytitle("Assessment accuracy")
		ylab(, angle(horiz))
		legend(off)	
		plotregion(style(none))
		text(58 1970.9 "Before reform", placement(left))
		text(58 1971.1 "After reform", placement(right))		
		text(47 1966 "Switched to appointed after 1971", size(small))
		text(45 1966 "(increased competence,", size(small))
		text(43 1966 "decreased incentives)", size(small))
		text(25 1976 "Remained elected after 1971", size(small))
		text(23 1976 "(increased competence,", size(small))
		text(21 1976 "same incentives)", size(small))
		xscale(range(1961.8 1981.2))
		xlab(1961(5)1981)
		;
	
#delimit cr

gr export "figure 6.eps", replace



* dif by year 
gen B = .
forvalues i = 1961(1)1981 {
	reg y held if year == `i'
	replace B = _b[held_referendum] if year == `i'
	
}
l year B if !mi(B)
